const Mock = require('mockjs')

const data = Mock.mock({
  'list|10': [{
    id: '@increment',
    name: '@first @last',
    'level|1': [0, 1, 2],
    productCount: '@integer(60, 500)',
    productUnit: '件',
    'navStatus|1': [0, 1],
    'showStatus|1': [0, 1],
    sort: 1
  }]
})

module.exports = [
  {
    url: '/productCategory/list/',
    type: 'get',
    response: config => {
      // parentId
      const { pageNum, pageSize } = config.query

      const mockList = data.list.filter(item => {
        return true
      })
      const pageList = mockList.filter((item, index) => index < pageNum * pageSize && index >= (pageNum - 1) * pageSize)
      return {
        code: 20000,
        data: {
          total: data.length,
          list: pageList
        }
      }
    }
  }
]
